function IsPC() {
  var userAgentInfo = navigator.userAgent.toLowerCase();
  var Agents = [
    "android",
    "iphone",
    "symbianos",
    "windows phone",
    "ipad",
    "ipod",
  ];
  var flag = true;
  for (var v = 0; v < Agents.length; v++) {
    if (userAgentInfo.indexOf(Agents[v]) > 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

const directives = {
  focus: {
    inserted: function (el) {
      if (IsPC()) {
        el.focus();

        el.onmouseover = function () {
          el.focus();
        };
      }
    },
  },
};

const install = (_Vue) => {
  if (!_Vue) return;

  for (const key in directives) {
    if (directives[key]) {
      _Vue.directive(key, directives[key]);
    }
  }
};

export default install;
